home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / cweb31p9d.lha / CWeb / wmerge.c < prev    next >
C/C++ Source or Header  |  1994-07-08  |  15KB  |  792 lines

  1. #define buf_size 100 \
  2.  
  3. #define max_include_depth 10 \
  4.  \
  5.  
  6. #define max_file_name_length 256 \
  7.  
  8. #define cur_file file[include_depth]
  9. #define cur_file_name file_name[include_depth]
  10. #define cur_line line[include_depth]
  11. #define web_file file[0]
  12. #define web_file_name file_name[0] \
  13.  
  14. #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \
  15. strncmp(buffer,change_buffer,(size_t) (limit-buffer) ) )  \
  16.  
  17. #define too_long() {include_depth--; \
  18. err_print("! Include file name too long") ;goto restart;} \
  19.  
  20. #define spotless 0
  21. #define harmless_message 1
  22. #define error_message 2
  23. #define fatal_message 3
  24. #define mark_harmless {if(history==spotless) history= harmless_message;}
  25. #define mark_error history= error_message \
  26.  
  27. #define fatal(s,t) { \
  28. fprintf(stderr,s) ;err_print(t) ; \
  29. history= fatal_message;exit(wrap_up() ) ; \
  30. } \
  31.  \
  32.  
  33. #define RETURN_OK 0
  34. #define RETURN_WARN 5
  35. #define RETURN_ERROR 10
  36. #define RETURN_FAIL 20 \
  37.  
  38. #define show_banner flags['b']
  39. #define show_happiness flags['h'] \
  40.  
  41. #define update_terminal fflush(stderr)  \
  42.  \
  43.  
  44. #define max_path_length 4095 \
  45.  
  46. /*1:*/
  47. #line 13 "wmerge.w"
  48.  
  49. #line 67 "wmerge.ch"
  50. #include <stdio.h>
  51. #include <string.h>
  52. #line 15 "wmerge.w"
  53. #include <stdlib.h> 
  54. #include <ctype.h> 
  55. /*2:*/
  56. #line 35 "wmerge.w"
  57.  
  58. typedef short boolean;
  59. typedef unsigned char eight_bits;
  60. typedef char ASCII;
  61.  
  62. /*:2*//*5:*/
  63. #line 68 "wmerge.w"
  64.  
  65. ASCII buffer[buf_size];
  66. ASCII*buffer_end= buffer+buf_size-2;
  67. ASCII*limit;
  68. ASCII*loc;
  69.  
  70. /*:5*//*7:*/
  71. #line 134 "wmerge.w"
  72.  
  73. int include_depth;
  74. FILE*file[max_include_depth];
  75. FILE*change_file;
  76. char file_name[max_include_depth][max_file_name_length];
  77.  
  78. char change_file_name[max_file_name_length];
  79. char alt_web_file_name[max_file_name_length];
  80. int line[max_include_depth];
  81. int change_line;
  82. int change_depth;
  83. boolean input_has_ended;
  84. boolean changing;
  85. boolean web_file_open= 0;
  86.  
  87. /*:7*//*8:*/
  88. #line 160 "wmerge.w"
  89.  
  90. char change_buffer[buf_size];
  91. char*change_limit;
  92.  
  93. /*:8*//*23:*/
  94. #line 478 "wmerge.w"
  95.  
  96. int history= spotless;
  97.  
  98. /*:23*//*30:*/
  99. #line 575 "wmerge.w"
  100.  
  101. int argc;
  102. char**argv;
  103. char out_file_name[max_file_name_length];
  104. #line 354 "wmerge.ch"
  105. boolean flags[256];
  106. #line 580 "wmerge.w"
  107.  
  108. /*:30*//*40:*/
  109. #line 692 "wmerge.w"
  110.  
  111. FILE*out_file;
  112.  
  113. /*:40*//*44:*/
  114. #line 426 "wmerge.ch"
  115.  
  116. char include_path[max_path_length+1]= CWEBINPUTS;
  117. char*p,*path_prefix,*next_path_prefix;
  118.  
  119. /*:44*//*46:*/
  120. #line 451 "wmerge.ch"
  121.  
  122. #ifdef _AMIGA
  123. const unsigned char*Version= "$VER: WMerge 3.1 [p9c] "__AMIGADATE__;
  124. #endif
  125.  
  126. /*:46*/
  127. #line 17 "wmerge.w"
  128.  
  129. /*4:*/
  130. #line 51 "wmerge.w"
  131.  
  132. #line 52 "wmerge.w"
  133.  
  134. /*:4*//*24:*/
  135. #line 279 "wmerge.ch"
  136.  
  137. #line 280 "wmerge.ch"
  138. void err_print(char*);
  139.  
  140. /*:24*//*32:*/
  141. #line 375 "wmerge.ch"
  142.  
  143. #line 376 "wmerge.ch"
  144. void scan_args(void);
  145.  
  146. /*:32*//*45:*/
  147. #line 433 "wmerge.ch"
  148.  
  149. int get_line(void);
  150. int input_ln(FILE*fp);
  151. int main(int argc,char**argv);
  152. int wrap_up(void);
  153. void check_change(void);
  154. void check_complete(void);
  155. void err_print(char*s);
  156. void prime_the_change_buffer(void);
  157. void put_line(void);
  158. void reset_input(void);
  159. void scan_args(void);
  160. static boolean set_path(char*ptr,char*override);
  161.  
  162. /*:45*/
  163. #line 18 "wmerge.w"
  164.  
  165. /*6:*/
  166. #line 93 "wmerge.w"
  167.  
  168. #line 84 "wmerge.ch"
  169. int input_ln(FILE*fp)
  170.  
  171. #line 96 "wmerge.w"
  172. {
  173. register int c= EOF;
  174. register char*k;
  175. if(feof(fp))return(0);
  176. limit= k= buffer;
  177. while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
  178. if((*(k++)= c)!=' ')limit= k;
  179. if(k>buffer_end)
  180. if((c= getc(fp))!=EOF&&c!='\n'){
  181. ungetc(c,fp);loc= buffer;err_print("! Input line too long");
  182.  
  183. }
  184. if(c==EOF&&limit==buffer)return(0);
  185.  
  186. return(1);
  187. }
  188.  
  189. /*:6*//*9:*/
  190. #line 171 "wmerge.w"
  191.  
  192. #line 110 "wmerge.ch"
  193. void prime_the_change_buffer(void)
  194. #line 174 "wmerge.w"
  195. {
  196. change_limit= change_buffer;
  197. /*10:*/
  198. #line 185 "wmerge.w"
  199.  
  200. while(1){
  201. change_line++;
  202. if(!input_ln(change_file))return;
  203. if(limit<buffer+2)continue;
  204. if(buffer[0]!='@')continue;
  205. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  206. if(buffer[1]=='x')break;
  207. if(buffer[1]=='y'||buffer[1]=='z'||buffer[1]=='i'){
  208. loc= buffer+2;
  209. err_print("! Missing @x in change file");
  210.  
  211. }
  212. }
  213.  
  214. /*:10*/
  215. #line 176 "wmerge.w"
  216. ;
  217. /*11:*/
  218. #line 202 "wmerge.w"
  219.  
  220. do{
  221. change_line++;
  222. if(!input_ln(change_file)){
  223. err_print("! Change file ended after @x");
  224.  
  225. return;
  226. }
  227. }while(limit==buffer);
  228.  
  229. /*:11*/
  230. #line 177 "wmerge.w"
  231. ;
  232. /*12:*/
  233. #line 212 "wmerge.w"
  234.  
  235. {
  236. change_limit= change_buffer-buffer+limit;
  237. #line 117 "wmerge.ch"
  238. strncpy(change_buffer,buffer,(size_t)(limit-buffer+1));
  239. #line 216 "wmerge.w"
  240. }
  241.  
  242. /*:12*/
  243. #line 178 "wmerge.w"
  244. ;
  245. }
  246.  
  247. /*:9*//*13:*/
  248. #line 230 "wmerge.w"
  249.  
  250. #line 125 "wmerge.ch"
  251. void check_change(void)
  252. #line 233 "wmerge.w"
  253. {
  254. int n= 0;
  255. if(lines_dont_match)return;
  256. while(1){
  257. changing= 1;change_line++;
  258. if(!input_ln(change_file)){
  259. err_print("! Change file ended before @y");
  260.  
  261. change_limit= change_buffer;changing= 0;
  262. return;
  263. }
  264. if(limit>buffer+1&&buffer[0]=='@'){
  265. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  266. /*14:*/
  267. #line 263 "wmerge.w"
  268.  
  269. if(buffer[1]=='x'||buffer[1]=='z'){
  270. loc= buffer+2;err_print("! Where is the matching @y?");
  271.  
  272. }
  273. else if(buffer[1]=='y'){
  274. if(n>0){
  275. loc= buffer+2;
  276. fprintf(stderr,"\n! Hmm... %d ",n);
  277. err_print("of the preceding lines failed to match");
  278.  
  279. }
  280. change_depth= include_depth;
  281. return;
  282. }
  283.  
  284. /*:14*/
  285. #line 247 "wmerge.w"
  286. ;
  287. }
  288. /*12:*/
  289. #line 212 "wmerge.w"
  290.  
  291. {
  292. change_limit= change_buffer-buffer+limit;
  293. #line 117 "wmerge.ch"
  294. strncpy(change_buffer,buffer,(size_t)(limit-buffer+1));
  295. #line 216 "wmerge.w"
  296. }
  297.  
  298. /*:12*/
  299. #line 249 "wmerge.w"
  300. ;
  301. changing= 0;cur_line++;
  302. while(!input_ln(cur_file)){
  303. if(include_depth==0){
  304. err_print("! CWEB file ended during a change");
  305.  
  306. input_has_ended= 1;return;
  307. }
  308. include_depth--;cur_line++;
  309. }
  310. if(lines_dont_match)n++;
  311. }
  312. }
  313.  
  314. /*:13*//*15:*/
  315. #line 282 "wmerge.w"
  316.  
  317. #line 133 "wmerge.ch"
  318. void reset_input(void)
  319. #line 285 "wmerge.w"
  320. {
  321. limit= buffer;loc= buffer+1;buffer[0]= ' ';
  322. /*16:*/
  323. #line 297 "wmerge.w"
  324.  
  325. if((web_file= fopen(web_file_name,"r"))==NULL){
  326. strcpy(web_file_name,alt_web_file_name);
  327. if((web_file= fopen(web_file_name,"r"))==NULL)
  328. fatal("! Cannot open input file ",web_file_name);
  329. }
  330.  
  331.  
  332. web_file_open= 1;
  333. if((change_file= fopen(change_file_name,"r"))==NULL)
  334. fatal("! Cannot open change file ",change_file_name);
  335.  
  336. /*:16*/
  337. #line 287 "wmerge.w"
  338. ;
  339. include_depth= 0;cur_line= 0;change_line= 0;
  340. change_depth= include_depth;
  341. changing= 1;prime_the_change_buffer();changing= !changing;
  342. limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= 0;
  343. }
  344.  
  345. /*:15*//*17:*/
  346. #line 315 "wmerge.w"
  347.  
  348. get_line()
  349. {
  350. restart:
  351. if(changing&&include_depth==change_depth)
  352. /*21:*/
  353. #line 423 "wmerge.w"
  354. {
  355. change_line++;
  356. if(!input_ln(change_file)){
  357. err_print("! Change file ended without @z");
  358.  
  359. buffer[0]= '@';buffer[1]= 'z';limit= buffer+2;
  360. }
  361. if(limit>buffer){
  362. *limit= ' ';
  363. if(buffer[0]=='@'){
  364. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  365. if(buffer[1]=='x'||buffer[1]=='y'){
  366. loc= buffer+2;
  367. err_print("! Where is the matching @z?");
  368.  
  369. }
  370. else if(buffer[1]=='z'){
  371. prime_the_change_buffer();changing= !changing;
  372. }
  373. }
  374. }
  375. }
  376.  
  377. /*:21*/
  378. #line 320 "wmerge.w"
  379. ;
  380. if(!changing||include_depth>change_depth){
  381. /*20:*/
  382. #line 407 "wmerge.w"
  383. {
  384. cur_line++;
  385. while(!input_ln(cur_file)){
  386. if(include_depth==0){input_has_ended= 1;break;}
  387. else{
  388. fclose(cur_file);include_depth--;
  389. if(changing&&include_depth==change_depth)break;
  390. cur_line++;
  391. }
  392. }
  393. if(!changing&&!input_has_ended)
  394. if(limit-buffer==change_limit-change_buffer)
  395. if(buffer[0]==change_buffer[0])
  396. if(change_limit>change_buffer)check_change();
  397. }
  398.  
  399. /*:20*/
  400. #line 322 "wmerge.w"
  401. ;
  402. if(changing&&include_depth==change_depth)goto restart;
  403. }
  404. loc= buffer;*limit= ' ';
  405. if(*buffer=='@'&&(*(buffer+1)=='i'||*(buffer+1)=='I')){
  406. loc= buffer+2;
  407. while(loc<=limit&&(*loc==' '||*loc=='\t'||*loc=='"'))loc++;
  408. if(loc>=limit){
  409. err_print("! Include file name not given");
  410.  
  411. goto restart;
  412. }
  413. if(include_depth>=max_include_depth-1){
  414. err_print("! Too many nested includes");
  415.  
  416. goto restart;
  417. }
  418. include_depth++;
  419. /*19:*/
  420. #line 366 "wmerge.w"
  421. {
  422. char temp_file_name[max_file_name_length];
  423. char*cur_file_name_end= cur_file_name+max_file_name_length-1;
  424. char*k= cur_file_name,*kk;
  425. int l;
  426.  
  427. while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
  428. if(k>cur_file_name_end)too_long();
  429.  
  430. *k= '\0';
  431. if((cur_file= fopen(cur_file_name,"r"))!=NULL){
  432. cur_line= 0;
  433. goto restart;
  434. }
  435. #line 213 "wmerge.ch"
  436.  
  437. #ifdef _AMIGA
  438. #define PATH_SEPARATOR   ','
  439. #define DIR_SEPARATOR    '/'
  440. #define DEVICE_SEPARATOR ':'
  441. #else
  442. #ifdef __TURBOC__
  443. #define PATH_SEPARATOR   ';'
  444. #define DIR_SEPARATOR    '\\'
  445. #define DEVICE_SEPARATOR ':'
  446. #else
  447. #define PATH_SEPARATOR   ':'
  448. #define DIR_SEPARATOR    '/'
  449. #define DEVICE_SEPARATOR '/'
  450. #endif
  451. #endif
  452.  
  453. if(0==set_path(include_path,getenv("CWEBINPUTS"))){
  454. include_depth--;goto restart;
  455. }
  456. path_prefix= include_path;
  457. while(path_prefix){
  458. for(kk= temp_file_name,p= path_prefix,l= 0;
  459. p&&*p&&*p!=PATH_SEPARATOR;
  460. *kk++= *p++,l++);
  461. if(path_prefix&&*path_prefix&&*path_prefix!=PATH_SEPARATOR&&
  462. *--p!=DEVICE_SEPARATOR&&*p!=DIR_SEPARATOR){
  463. *kk++= DIR_SEPARATOR;l++;
  464. }
  465. if(k+l+2>=cur_file_name_end)too_long();
  466. strcpy(kk,cur_file_name);
  467. if(cur_file= fopen(temp_file_name,"r")){
  468. cur_line= 0;goto restart;
  469. }
  470. if(next_path_prefix= strchr(path_prefix,PATH_SEPARATOR))
  471. path_prefix= next_path_prefix+1;
  472. else break;
  473. }
  474. #line 404 "wmerge.w"
  475. include_depth--;err_print("! Cannot open include file");goto restart;
  476. }
  477.  
  478. /*:19*/
  479. #line 340 "wmerge.w"
  480. ;
  481. }
  482. return(!input_has_ended);
  483. }
  484.  
  485. #line 147 "wmerge.ch"
  486. void put_line(void)
  487. {
  488. char*ptr= buffer;
  489. while(ptr<limit)
  490. {
  491. putc(*ptr,out_file);
  492. *ptr++;
  493. }
  494. putc('\n',out_file);
  495. }
  496. #line 351 "wmerge.w"
  497.  
  498. #line 171 "wmerge.ch"
  499. /*:17*//*22:*/
  500. #line 449 "wmerge.w"
  501.  
  502. #line 258 "wmerge.ch"
  503. void check_complete(void){
  504. #line 452 "wmerge.w"
  505. if(change_limit!=change_buffer){
  506. #line 265 "wmerge.ch"
  507. strncpy(buffer,change_buffer,(size_t)(change_limit-change_buffer+1));
  508. #line 454 "wmerge.w"
  509. limit= buffer+(int)(change_limit-change_buffer);
  510. changing= 1;change_depth= include_depth;loc= buffer;
  511. err_print("! Change file entry did not match");
  512.  
  513. }
  514. }
  515.  
  516. /*:22*//*25:*/
  517. #line 283 "wmerge.ch"
  518.  
  519. void err_print(char*s)
  520. #line 498 "wmerge.w"
  521. {
  522. char*k,*l;
  523. fprintf(stderr,*s=='!'?"\n%s":"%s",s);
  524. if(web_file_open)/*26:*/
  525. #line 514 "wmerge.w"
  526.  
  527. {if(changing&&include_depth==change_depth)
  528. printf(". (l. %d of change file)\n",change_line);
  529. else if(include_depth==0)fprintf(stderr,". (l. %d)\n",cur_line);
  530. else fprintf(stderr,". (l. %d of include file %s)\n",cur_line,cur_file_name);
  531. l= (loc>=limit?limit:loc);
  532. if(l>buffer){
  533. for(k= buffer;k<l;k++)
  534. if(*k=='\t')putc(' ',stderr);
  535. else putc(*k,stderr);
  536. putchar('\n');
  537. for(k= buffer;k<l;k++)putc(' ',stderr);
  538. }
  539. for(k= l;k<limit;k++)putc(*k,stderr);
  540. putc('\n',stderr);
  541. }
  542.  
  543. /*:26*/
  544. #line 501 "wmerge.w"
  545. ;
  546. update_terminal;mark_error;
  547. }
  548.  
  549. /*:25*//*28:*/
  550. #line 318 "wmerge.ch"
  551.  
  552. #ifndef __TURBOC__
  553. int wrap_up(void){
  554. /*29:*/
  555. #line 553 "wmerge.w"
  556.  
  557. switch(history){
  558. case spotless:if(show_happiness)fprintf(stderr,"(No errors were found.)\n");break;
  559. case harmless_message:
  560. fprintf(stderr,"(Did you see the warning message above?)\n");break;
  561. case error_message:
  562. fprintf(stderr,"(Pardon me, but I think I spotted something wrong.)\n");break;
  563. case fatal_message:fprintf(stderr,"(That was a fatal error, my friend.)\n");
  564. }
  565.  
  566. /*:29*/
  567. #line 321 "wmerge.ch"
  568. ;
  569. switch(history){
  570. case harmless_message:return(RETURN_WARN);break;
  571. case error_message:return(RETURN_ERROR);break;
  572. case fatal_message:return(RETURN_FAIL);break;
  573. default:return(RETURN_OK);
  574. }
  575. }
  576. #else
  577. int wrap_up(void){
  578. int return_val;
  579.  
  580. /*29:*/
  581. #line 553 "wmerge.w"
  582.  
  583. switch(history){
  584. case spotless:if(show_happiness)fprintf(stderr,"(No errors were found.)\n");break;
  585. case harmless_message:
  586. fprintf(stderr,"(Did you see the warning message above?)\n");break;
  587. case error_message:
  588. fprintf(stderr,"(Pardon me, but I think I spotted something wrong.)\n");break;
  589. case fatal_message:fprintf(stderr,"(That was a fatal error, my friend.)\n");
  590. }
  591.  
  592. /*:29*/
  593. #line 333 "wmerge.ch"
  594. ;
  595. switch(history){
  596. case harmless_message:return_val= RETURN_WARN;break;
  597. case error_message:return_val= RETURN_ERROR;break;
  598. case fatal_message:return_val= RETURN_FAIL;break;
  599. default:return_val= RETURN_OK;
  600. }
  601. return(return_val);
  602. }
  603. #endif
  604. #line 552 "wmerge.w"
  605.  
  606. /*:28*//*33:*/
  607. #line 379 "wmerge.ch"
  608.  
  609. void scan_args(void)
  610. #line 606 "wmerge.w"
  611. {
  612. char*dot_pos;
  613. char*name_pos;
  614. register char*s;
  615. boolean found_web= 0,found_change= 0,found_out= 0;
  616.  
  617. boolean flag_change;
  618.  
  619. while(--argc>0){
  620. if(**(++argv)=='-'||**argv=='+')/*37:*/
  621. #line 674 "wmerge.w"
  622.  
  623. {
  624. if(**argv=='-')flag_change= 0;
  625. else flag_change= 1;
  626. for(dot_pos= *argv+1;*dot_pos>'\0';dot_pos++)
  627. flags[*dot_pos]= flag_change;
  628. }
  629.  
  630. /*:37*/
  631. #line 615 "wmerge.w"
  632.  
  633. else{
  634. s= name_pos= *argv;dot_pos= NULL;
  635. while(*s){
  636. if(*s=='.')dot_pos= s++;
  637. else if(*s=='/')dot_pos= NULL,name_pos= ++s;
  638. else s++;
  639. }
  640. if(!found_web)/*34:*/
  641. #line 640 "wmerge.w"
  642.  
  643. {
  644. if(s-*argv>max_file_name_length-5)
  645. /*39:*/
  646. #line 687 "wmerge.w"
  647. fatal("! Filename too long\n",*argv);
  648.  
  649. /*:39*/
  650. #line 643 "wmerge.w"
  651. ;
  652. if(dot_pos==NULL)
  653. sprintf(web_file_name,"%s.w",*argv);
  654. else{
  655. strcpy(web_file_name,*argv);
  656. *dot_pos= 0;
  657. }
  658. sprintf(alt_web_file_name,"%s.web",*argv);
  659. *out_file_name= '\0';
  660. found_web= 1;
  661. }
  662.  
  663. /*:34*/
  664. #line 623 "wmerge.w"
  665.  
  666. else if(!found_change)/*35:*/
  667. #line 655 "wmerge.w"
  668.  
  669. {
  670. if(s-*argv>max_file_name_length-4)
  671. /*39:*/
  672. #line 687 "wmerge.w"
  673. fatal("! Filename too long\n",*argv);
  674.  
  675. /*:39*/
  676. #line 658 "wmerge.w"
  677. ;
  678. if(dot_pos==NULL)
  679. sprintf(change_file_name,"%s.ch",*argv);
  680. else strcpy(change_file_name,*argv);
  681. found_change= 1;
  682. }
  683.  
  684. /*:35*/
  685. #line 624 "wmerge.w"
  686.  
  687. else if(!found_out)/*36:*/
  688. #line 665 "wmerge.w"
  689.  
  690. {
  691. if(s-*argv>max_file_name_length-5)
  692. /*39:*/
  693. #line 687 "wmerge.w"
  694. fatal("! Filename too long\n",*argv);
  695.  
  696. /*:39*/
  697. #line 668 "wmerge.w"
  698. ;
  699. if(dot_pos==NULL)sprintf(out_file_name,"%s.out",*argv);
  700. else strcpy(out_file_name,*argv);
  701. found_out= 1;
  702. }
  703.  
  704. /*:36*/
  705. #line 625 "wmerge.w"
  706.  
  707. else/*38:*/
  708. #line 682 "wmerge.w"
  709.  
  710. {
  711. fatal("! Usage: wmerge webfile[.w] [changefile[.ch] [outfile[.out]]]\n","")
  712. }
  713.  
  714. /*:38*/
  715. #line 626 "wmerge.w"
  716. ;
  717. }
  718. }
  719. if(!found_web)/*38:*/
  720. #line 682 "wmerge.w"
  721.  
  722. {
  723. fatal("! Usage: wmerge webfile[.w] [changefile[.ch] [outfile[.out]]]\n","")
  724. }
  725.  
  726. /*:38*/
  727. #line 629 "wmerge.w"
  728. ;
  729. #line 386 "wmerge.ch"
  730. #if defined( __TURBOC__ )
  731. if(!found_change)strcpy(change_file_name,"nul");
  732. #elif defined( _AMIGA )
  733. if(!found_change)strcpy(change_file_name,"NIL:");
  734. #else
  735. if(!found_change)strcpy(change_file_name,"/dev/null");
  736. #endif
  737. #line 631 "wmerge.w"
  738. }
  739.  
  740. /*:33*//*43:*/
  741. #line 405 "wmerge.ch"
  742.  
  743. static boolean set_path(char*ptr,char*override)
  744. {
  745. if(override){
  746. if(strlen(override)>=max_path_length){
  747. err_print("! Include path too long");return(0);
  748.  
  749. }
  750. else strcpy(ptr,override);
  751. }
  752. return(1);
  753. }
  754.  
  755. /*:43*/
  756. #line 19 "wmerge.w"
  757.  
  758. main(ac,av)
  759. int ac;char**av;
  760. {
  761. argc= ac;argv= av;
  762. /*31:*/
  763. #line 583 "wmerge.w"
  764.  
  765. show_banner= show_happiness= 1;
  766.  
  767. /*:31*/
  768. #line 24 "wmerge.w"
  769. ;
  770. /*41:*/
  771. #line 695 "wmerge.w"
  772.  
  773. scan_args();
  774. if(out_file_name[0]=='\0')out_file= stdout;
  775. else if((out_file= fopen(out_file_name,"w"))==NULL)
  776. fatal("! Cannot open output file ",out_file_name);
  777.  
  778.  
  779. /*:41*/
  780. #line 25 "wmerge.w"
  781. ;
  782. reset_input();
  783. while(get_line())
  784. put_line();
  785. fflush(out_file);
  786. check_complete();
  787. fflush(out_file);
  788. return wrap_up();
  789. }
  790.  
  791. /*:1*/
  792.